package br.edu.senai.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Conexao {
    private static final String URL = "jdbc:mysql://localhost:3306/test";
    private static final String USER = "root";
    private static final String PASSWORD = "";
    
    public static Connection conectar() {
        try {
            Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);
            return conn;                    
        } catch (SQLException ex) {
            System.out.println("Erro ao tentar conectar no banco: " + ex.getMessage());
        }
        return null;
    }
    
    public static void desconectar(Connection conn) {
        try {
            conn.close();
        } catch (SQLException ex) {
            System.out.println("Erro ao tentar desconectar do banco: " + ex.getMessage());
        }
    }
}
